package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.ssxcx.entity.SubjectLessonVideo;
import com.dingreading.cloud.ssxcx.entity.table.SubjectLessonVideoTableDef;
import com.dingreading.cloud.ssxcx.mapper.SubjectLessonVideoMapper;
import com.dingreading.cloud.ssxcx.service.SubjectLessonVideoService;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

/**
 * 服务层实现。
 *
 * @author EDY
 * @since 2025-09-22
 */
@Service
public class SubjectLessonVideoServiceImpl extends BaseServiceImpl<SubjectLessonVideoMapper, SubjectLessonVideo, SubjectLessonVideoTableDef> implements SubjectLessonVideoService {

    @Override
    protected SubjectLessonVideoTableDef getTable() {
        return SubjectLessonVideoTableDef.subjectLessonVideo;
    }

    @Override
    public SubjectLessonVideo getByLessonUid(String subjectLessonUid) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.lessonUid.eq(subjectLessonUid))
                .and(table.enabled.eq(1));
        QueryWrapper wrapper = QueryWrapper.create()
                .where(condition)
                .limit(1);
        return getMapper().selectOneByQuery(wrapper);
    }
}
